package net.hn.hnms.biz.intelligence.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import net.hn.hnms.biz.intelligence.service.SafetyIndexService;
import net.hn.hnms.biz.intelligence.vo.AlarmCountByLevelVO;
import net.hn.hnms.biz.intelligence.vo.AlarmCountBySystemVO;
import net.hn.hnms.biz.intelligence.vo.NameValueVO;
import net.hn.hnms.sys.common.core.domain.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;


@RestController
@RequestMapping("index")
@Api(value = "公司端安全综合概览首页", tags = {"公司端安全综合概览首页"})
@RequiredArgsConstructor
public class SafetyIndexController {

    private final SafetyIndexService safetyIndexService;


    @GetMapping("/alarmCountByLevel")
    @ApiOperation("四色预警数")
    public R<List<NameValueVO>> alarmCountByLevel() {
        AlarmCountByLevelVO vo = safetyIndexService.alarmCountByLevel();
        List<NameValueVO> lst = new ArrayList<>();
        lst.add(new NameValueVO("红色风险数", vo.getAlarmCountRed()));
        lst.add(new NameValueVO("橙色风险数", vo.getAlarmCountOrange()));
        lst.add(new NameValueVO("黄色风险数", vo.getAlarmCountYellow()));
        lst.add(new NameValueVO("蓝色风险数", vo.getAlarmCountBlue()));
        return R.ok(lst);
    }

    @GetMapping("/alarmCountBySystem")
    @ApiOperation("各系统告警数")
    public R<AlarmCountBySystemVO> alarmCountBySystem(@ApiParam("week或month") @RequestParam(defaultValue = "week") String type) {
        return R.ok(safetyIndexService.alarmCountBySystem(type));
    }
}
